import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
import { JVxeTypes, JVxeColumn } from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '计划编号',
    align: "center",
    dataIndex: 'billCode',
    width: 140
  },
  {
    title: '计划名称',
    align: "center",
    dataIndex: 'planName',
    width: 120
  },
  {
    title: '版本号',
    align: "center",
    dataIndex: 'planVersion',
    width: 80
  },
  {
    title: '计划时间',
    align: "center",
    dataIndex: 'planTime',
    width: 150
  },
  {
    title: 'MRP运算状态',
    align: "center",
    dataIndex: 'mrpCalculateStatus',
    customRender: ({
      text
    }) => text === 0 ? '未运算' : text === 1 ? '运算中' : '运算完成',
    width: 110
  },
  {
    title: '计划员',
    align: "center",
    dataIndex: 'plannerName',
    width: 100
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [{
  label: "计划编号",
  field: "billCode",
  component: 'Input',
  colProps: {
    span: 6
  },
},
{
  label: "计划员",
  field: "plannerName",
  component: 'Input',
  colProps: {
    span: 6
  },
},
{
  label: "来源类型",
  field: "srcDocType",
  component: 'Select',
  componentProps: {
    options: [{
      label: '原订单',
      value: 0
    }, {
      label: '总装排产',
      value: 1
    }, {
      label: '主生产计划',
      value: 2
    }],
    stringToNumber: true,
  },
  colProps: {
    span: 6
  },
},
];
// 基本信息表单数据
export const basicinformationFormSchema: FormSchema[] = [
  {
    label: 'id',
    field: 'id',
    component: 'Input',
    dynamicDisabled: true,
    show: false
  },
  {
    label: '计划编号',
    field: 'billCode',
    component: 'Input',
    dynamicDisabled: true,
    componentProps: {
      placeholder: '后台自动生成',
    },
  },
  {
    label: '计划名称',
    field: 'planName',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{
        required: true,
        message: '请输入计划名称!'
      },];
    },
  },
]
//子表单数据
//子表表格配置
// 计划订单  列表
export const psPlanOrderItemColumns: JVxeColumn[] = [{
  title: '计划订单ID',
  key: 'planOrderId',
  type: JVxeTypes.hidden,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '来源类型',
  key: 'srcDocType',
  type: JVxeTypes.slot,
  width: "140px",
  defaultValue: '',
  slotName: 'srcDocTypeSlot'
},
{
  title: '销售订单号',
  key: 'orderNumber',
  width: "150px",
  type: JVxeTypes.normal,
  disabled: true,
},
{
  title: '行号',
  key: 'orderRowNumber',
  type: JVxeTypes.normal,
  width: "80px",
},
{
  title: '产品编码',
  key: 'materialCode',
  type: JVxeTypes.normal,
  width: "150px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '产品名称',
  key: 'materialName',
  type: JVxeTypes.normal,
  width: "150px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '产品规格',
  key: 'spec',
  type: JVxeTypes.normal,
  width: "150px",
  placeholder: '请输入${title}',
  defaultValue: '',
  disabled: true,
},
{
  title: '产品id',
  key: 'materialId',
  type: JVxeTypes.hidden,
  width: "120px",
  placeholder: '请输入${title}',
  defaultValue: '',
  disabled: true,
},
{
  title: '单位ID',
  key: 'unitId',
  type: JVxeTypes.hidden,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '单位',
  key: 'unitName',
  width: "100px",
  type: JVxeTypes.normal,
},
{
  title: '排产数量',
  key: 'orderQuantity',
  type: JVxeTypes.normal,
  width: "100px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '订单交期',
  key: 'orderDeliveryDate',
  type: JVxeTypes.date,
  width: "140px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '操作',
  key: 'action',
  width: '100px',
  fixed: 'right',
  align: 'center',
  type: JVxeTypes.slot,
  slotName: 'action',
},
]
// mrp计算结果 列表
export const psPlanOrderResultColumns: JVxeColumn[] = [{
  title: '计划订单ID',
  key: 'planOrderId',
  type: JVxeTypes.hidden,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '行号',
  key: 'rowNum',
  type: JVxeTypes.normal,
  width: "80px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '生产组织ID',
  key: 'productOrganizationId',
  type: JVxeTypes.hidden,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '生产组织',
  key: 'productOrganizationName',
  type: JVxeTypes.hidden,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '版本号',
  key: 'resultVersion',
  type: JVxeTypes.normal,
  width: "100px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '料品ID',
  key: 'materialId',
  type: JVxeTypes.hidden,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '料品',
  key: 'materialName',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '料品编号',
  key: 'materialCode',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
  disabled: true
},
{
  title: '料品规格',
  key: 'spec',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
  disabled: true
},
{
  title: '单位ID',
  key: 'unitId',
  type: JVxeTypes.hidden,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '单位',
  key: 'unitName',
  width: "200px",
  type: JVxeTypes.normal,
  disabled: true
},
{
  title: '供应类型', // 0自制 1采购 2委外
  key: 'supplyType',
  type: JVxeTypes.select,
  width: "200px",
  options: [{
    value: 0,
    label: '自制'
  }, {
    value: 1,
    label: '采购'
  }, {
    value: 2,
    label: '委外'
  }],
  placeholder: '请选择${title}',
  defaultValue: '',
},
{
  title: '供应商ID',
  key: 'supplierId',
  type: JVxeTypes.hidden,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '供应商',
  key: 'supplierName',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '排产数量',
  key: 'orderQuantity',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: 'MRP数量',
  key: 'mrpQuantity',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '调整后MRP数量',
  key: 'adjustedMrpQuantity',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '释放量',
  key: 'releaseQuantity',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '需求日期',
  key: 'demandDate',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '开工日期',
  key: 'startDate',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '需求类型', // 0独立 1相关
  key: 'demandType',
  type: JVxeTypes.select,
  width: "200px",
  options: [{
    value: 0,
    label: '独立'
  }, {
    value: 1,
    label: '相关'
  }],
  placeholder: '请选择${title}',
  defaultValue: '',
},
{
  title: '释放状态', //0未释放 1已释放
  key: 'releaseStatus',
  type: JVxeTypes.select,
  width: "200px",
  options: [{
    value: 0,
    label: '未释放'
  }, {
    value: 1,
    label: '已释放'
  }],
  placeholder: '请选择${title}',
  defaultValue: '',
},
{
  title: '是否排产', // 0否 1是
  key: 'productScheduleStatus',
  type: JVxeTypes.select,
  width: "200px",
  options: [{
    value: 0,
    label: '否'
  }, {
    value: 1,
    label: '是'
  }],
  placeholder: '请选择${title}',
  defaultValue: '',
},
{
  title: '锁定状态', // 0未锁定 1已锁定
  key: 'lockStatus',
  type: JVxeTypes.select,
  width: "200px",
  options: [{
    value: 0,
    label: '未锁定'
  }, {
    value: 1,
    label: '已锁定'
  }],
  placeholder: '请选择${title}',
  defaultValue: '',
},
{
  title: '来源行号',
  key: 'orderRowNumber',
  type: JVxeTypes.normal,
  width: "100px",
  defaultValue: '',
},
// {
//   title: '源头单据ID',
//   key: 'firstBillId',
//   type: JVxeTypes.hidden,
//   width: "200px",
//   placeholder: '请输入${title}',
//   defaultValue: '',
// },
{
  title: '来源订单号',
  key: 'orderBillCode',
  type: JVxeTypes.normal,
  width: "140px",
},
{
  title: '备注',
  key: 'remark',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '第三方编码',
  key: 'thirdPartyCode',
  type: JVxeTypes.hidden,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '组织ID',
  key: 'organizationId',
  type: JVxeTypes.hidden,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '租户ID',
  key: 'tenantId',
  type: JVxeTypes.hidden,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
]
// mrp计算结果 列表
export const supplyAndDemandColumns: JVxeColumn[] = [
  {
    title: '行号',
    key: 'rowNum',
    type: JVxeTypes.normal,
    width: "80px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },{
  title: '供/需',
  key: 'planOrderId',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},

{
  title: '订单类型',
  key: 'productOrganizationId',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '产品编码',
  key: 'productOrganizationName',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '产品名称',
  key: 'resultVersion',
  type: JVxeTypes.normal,
  width: "100px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '单位',
  key: 'uomName',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '数量',
  key: 'qty',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
},
{
  title: '存储地点',
  key: 'whName',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
  disabled: true
},
{
  title: '供应日期',
  key: 'srcDate',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
  disabled: true
},
{
  title: '销售订单号',
  key: 'srcOrderNo',
  type: JVxeTypes.normal,
  width: "200px",
  placeholder: '请输入${title}',
  defaultValue: '',
}
]
// 计划订单 日志  列表
export const psPlanOrderLogColumns: JVxeColumn[] = [
  // {
  //   title: '行号',
  //   key: 'rowNum',
  //   type: JVxeTypes.normal,
  //   width: "80px",
  // },
  // {
  //   title: '日志日期',
  //   key: 'logTime',
  //   type: JVxeTypes.normal,
  // },
  {
    title: '开始时间',
    key: 'startTime',
    type: JVxeTypes.normal,
  },
  {
    title: '结束时间',
    key: 'finishTime',
    type: JVxeTypes.normal,
  },
  {
    title: '耗时(毫秒)',
    key: 'costTime',
    type: JVxeTypes.normal,
  },
  {
    title: '执行状态',
    key: 'executeStatus',
    type: JVxeTypes.slot,
    slotName: 'executeStatusSlot'
  },
  {
    title: '错误信息',
    key: 'message',
    type: JVxeTypes.normal
  },
  // {
  //   title: '说明',
  //   key: 'description',
  //   type: JVxeTypes.normal,
  //   // width: "120px",
  // },
];

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
